package second.juc;


/**
 * @author: heweiwei
 * @Date: 2023/1/29 17:52
 * @Desc:
 */
public class WaitNotifyTest {

    static Object objectLock = new Object();

    public static void main(String[] args) {

        new Thread(() -> {
            synchronized (objectLock) {
                System.out.println(Thread.currentThread().getName() + "\t" + "----come in");
                try {
                    objectLock.wait();
                    System.out.println(Thread.currentThread().getName() + "\t" + "----end ");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "A").start();


        new Thread(() -> {
            synchronized (objectLock) {
                System.out.println(Thread.currentThread().getName() + "\t" + "----come in");
                objectLock.notify();
                System.out.println(Thread.currentThread().getName() + "\t" + "----end ");
            }
        }, "B").start();

    }
}
